package com.da.boot.exception;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @author JokerDa.
 * @date 2021/1/23 23:35
 * Description: 处理整个web controller的异常
 */
@Slf4j
@ControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 处理异常
     */
    @ExceptionHandler({ArithmeticException.class, NullPointerException.class})
    public String handleArithmeticException(Exception e) {
        log.error("异常是：{}", e);
        //视图地址
        return "login";
    }
}